<template>
	<view class="scan-container">
		<fui-nav-bar title="签约销售商" isFixed isOccupy  @leftClick="pageBack"></fui-nav-bar>
		<image src="/static/owners/saomayaoqing.png" mode="" class="scan-image"></image>
		<!-- #ifdef H5 -->
		<view class="u-p-35">
			<fui-input maxlength="999" v-model="value" :type="'textarea'" placeholder="输入二维码解码信息" :border="true"  />
		</view>
		<!-- #endif -->
		
		<button type="default" class="scan-button" @click="scanCodeFn">扫码邀请</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value:'',
			}
		},
		async onShow() {
		},
		async onLoad() {
		},
		onReady() {
			
		},  
		methods:{
			scanCodeFn(){
				
				// #ifdef APP-PLUS
				// console.log(plus.runtime.isAgreePrivacy());
					uni.scanCode({
						success:  (res) => {
							this.$mHelper.delayedJump(`/pages/purchase/mySale/signContract?type=code&qrcode=${res.result}`,'push',1000);
						},
						fail:(Error)=>{
							this.$u.toast('识别二维码失败')
						}
					});
				// #endif
				// #ifdef H5
					// return this.$u.toast('网页版不支持此功能');
					if(this.value === ''){
						return this.$u.toast('二维码解码信息不得为空');
					}else{
						this.$mRouter.push({ route: '/pages/purchase/mySale/signContract?type=code&qrcode='+this.value});
					}
					// this.getUserIdFn('C1A828A4F7325FFFD2BFB66C3802B26EE5F386EC4EF85108FD72F1D5B2E6C7256990CB09953674B5')
				// #endif
			},
			// Shop/QRShopEmployee
			async getUserIdFn(QRcode){
				uni.showLoading({
					title:'loading..'
				});
				const res = await this.$newHttp.post('api/Common/UserIdDecode',{code:QRcode});
				uni.hideLoading();
				console.log(res);
				if(res.code == 200){
					this.$mRouter.push({ route: '/pages/mine/createShop/index?type=saleAdd&userId='+res.data });
				}else{
					this.$u.toast('获取用户信息失败，请重新扫码')
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.scan-container{
		background-color: #fff;
		height: 100%;
	}
	.scan-image{
		width: 426rpx;
		height: 404rpx;
		display: block;
		margin: 340rpx auto 130rpx;
		
	}
	.scan-button{
		width: 380rpx;
		height: 90rpx;
		background: linear-gradient(-90deg, #FFBB1A, #FFBB1A);
		border-radius: 45px;
		font-size: 30rpx;
		line-height: 90rpx;
	}
</style>
